<?php
require_once ("src/db/connectdatabase.php");

function getNews($idtype) {
	$con = new ConnectDB();
	$tbl = "news";
	$fn = array('new_id', 'new_title', 'datecreate', 'new_tomtat');
	$condetion = array('idtnew' => $idtype);
	return $con -> getvalueorderby($tbl, $fn, $condetion, 'datecreate');
}

function getTypeNew($idtype) {
	$con = new ConnectDB();
	
	$sql = "SELECT idtnew, nametypenew FROM typenews WHERE idtnew=".$idtype;
	return $con -> getvalueString($sql);
}

function int_to_date($int)
{
    $time  = date("d/m/Y", $int);
    return $time;
}
$idtype = "";
if(isset($_GET['tp'])) {
	$idtype = $_GET['tp'];
	$typnew = getTypeNew($idtype);
	$arrnews = getNews($idtype);
	
	$namettintuc = "Tin Tức";
	if(count($typnew) > 0) {
		$namettintuc = $typnew[0][1];
	}
?>	
<script type="text/javascript">
    document.title = "Tin tức thị trường tài chính mới nhất - Tài Chính Online";
</script>
<style>
.tblwt_txt {
	color: #FFFFFF;
	font-size: 13px;
	font-weight: bold;
	padding: 2px;
}

.tbl_txt {
	color: #373737;
	font-size: 11px;
	padding: 2px;
}

#txt .link-click-xemthem-class {
	color: #666666;
	font-size: 11px;
	line-height: 15px;
	text-decoration: none;
}

#txt .link-click-xemthem-class {
	text-decoration: none;
}

#txt .link-click-xemthem-class:hover {
	color: #8DAE48;
	text-decoration:none;
}
</style>
<div class="text12" style="margin: auto; width: 970px; height: 11px; margin-top: 11px; color: #0a8bd9;">
	<u><a href="<?php echo($host) ?>" class="text12" style="color: #0080d6;">Trang Chủ</a></u>&gt; <u><a href="<?php echo($host) ?>tin-tuc-truyen-thong.html" class="text12" style="color: #0080d6;">Tin Tức</a></u>&gt; <a href="#" class="text12" style="color: #4c4c4c;"><?php echo($namettintuc) ?></a></span>
</div>
<div class="intrl_txt" style="margin: auto;">
    <div style="float: left; width: 660px; margin-top: 20px; clear: right;">
        <div id="txt" class="main-show-news">
            <table width="660" border="0" cellpadding="1" cellspacing="1" bgcolor="#d5cfb1">
                <tbody>
                    <tr bgcolor="#8DAE48">
                        <td height="30" align="left" class="tblwt_txt" style="padding-left: 3px; font-size: 14px;"><b><?php echo($namettintuc) ?></b></td>
                    </tr>
                	<?php
					foreach($arrnews as $entry) {
						$strbanknameurl2 = $entry[1];
						$strbanknameurl2 = rewriteTextUrl(stripUnicode($strbanknameurl2));
					?>
                    <tr bgcolor="#EFEEEE">
                        <td style="min-height: 50px" align="left" bgcolor="#FFFFFF" class="tbl_txt"><div style="position: relative; margin-bottom: 15px;"><div style="height:5px; width: 100%;"></div><div><strong><a class="link-click-xemthem-class" href="<?php echo($host) ?>tin-tuc/detail/<?php echo($entry[0]) ?>/<?php echo($strbanknameurl2) ?>.html"><?php echo($entry[1]) ?></a></strong> <br /><p><?php echo($entry[3]) ?></p> </div><div style="clear:both;"><span style="position: absolute; right: 5px; bottom: -15px;"><?php echo(int_to_date($entry[2])) ?></span></div></div></td>
                    </tr>
                    <tr></tr>
                    <?php
					}
					?>
                </tbody>
            </table>
        </div>
    </div>
	
    <div style="float: right; clear: right; background-image: url(<?php echo($host) ?>images/gray_bg.gif); width: 275px; height: auto; margin-top: 10px;">
        <?php include("formsendapplyloan.php"); ?>
    </div>
</div>
	<?php
}
?>
<style>
	.main-show-news img {
		margin-right: 5px;
		margin-bottom: 5px;
	}
</style>